﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace NailManager
{
    public partial class LoginForm : Form
    {
        private bool mousePressed = false;
        private Point diff = new Point(0, 0);

        Panel panel = new Panel();
        Label title = new Label();
        Label userLB = new Label();
        Label passLB = new Label();
        TextBox userTB = new TextBox();
        TextBox passTB = new TextBox();
        Button loginBT = new Button();
        mButton exitBT = new mButton();
        public LoginForm()
        {
            InitializeComponent();
            this.SetStyle(ControlStyles.DoubleBuffer | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true);
            this.UpdateStyles();
        }

        private void LoginForm_Load(object sender, EventArgs e)
        {
            BitmapRegion.CreateControlRegion(this,new Bitmap(@"images\khung2.png"));
            panel.Size = new Size(500, 300);
            panel.Location = new Point((this.Width - panel.Width) / 2, (this.Height - panel.Height) / 2);
            panel.BackColor = Color.Transparent;
            this.Controls.Add(panel);

            title.Text = "Login";
            title.Font = new System.Drawing.Font("Arial", 18F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            title.Size = new Size(80, 40);
            title.Location = new Point((panel.Width - title.Width) / 2, 15);
            panel.Controls.Add(title);
            exitBT.Imagepath = @"images\close6.jpg";
            exitBT.Location = new Point(this.Width - 50,0);
            exitBT.MouseClick += new MouseEventHandler(exitBT_MouseClick);
            this.Controls.Add(exitBT);

            Size tbSize = new Size(200, 30);

            userLB.Text = "User Name";
            userLB.Location = new Point(70,title.Location.Y + 70);
            userLB.Font = new System.Drawing.Font("Arial", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            panel.Controls.Add(userLB);

            userTB.Location = new Point(userLB.Location.X + 150, userLB.Location.Y);
            userTB.Size = tbSize;
            panel.Controls.Add(userTB);

            passLB.Text = "Password";
            passLB.Location = new Point(userLB.Location.X, userLB.Location.Y + 50);
            passLB.Font = new System.Drawing.Font("Arial", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            panel.Controls.Add(passLB);

            passTB.Location = new Point(userTB.Location.X, passLB.Location.Y);
            passTB.Size = tbSize;
            panel.Controls.Add(passTB);

            loginBT.Text = "Login";
            loginBT.Size = new Size(120, 30);
            loginBT.Location = new Point((panel.Width - loginBT.Width) / 2, passTB.Location.Y + 50);
            loginBT.Font = new System.Drawing.Font("Arial", 13F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            panel.Controls.Add(loginBT);

            
           
            
            
            
        }

        void exitBT_MouseClick(object sender, MouseEventArgs e)
        {
            this.Close();
        }

        private void LoginForm_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                mousePressed = true;

                Point p = new Point(e.X, e.Y);
                p = PointToScreen(p);
                diff.X = p.X - DesktopLocation.X;
                diff.Y = p.Y - DesktopLocation.Y;
            }
        }

        private void LoginForm_MouseUp(object sender, MouseEventArgs e)
        {
            mousePressed = false;
        }

        private void LoginForm_MouseMove(object sender, MouseEventArgs e)
        {
            if (mousePressed && (e.Button & MouseButtons.Left) != 0)
            {
                Point p = new Point(e.X, e.Y);
                p = PointToScreen(p);
                p.X -= diff.X;
                p.Y -= diff.Y;
                DesktopLocation = p;
            }  
        }
    }
}
